package org.javabasic;

/**
 * @Auther: qingle
 * @Date: 2024/8/23-19:23
 * @Description:
 * @version: 1.0
 */
public class MyClass_44_Person2 {
		private final int id;
		private final String name;

		public MyClass_44_Person2(int id, String name) {
			this.id = id;
			this.name = name;
		}

		@Override
		public boolean equals(Object o) {
			if (this == o) return true;
			if (o == null || getClass() != o.getClass()) return false;
			MyClass_44_Person2 person = (MyClass_44_Person2) o;
			return id == person.id;
		}

		@Override
		public int hashCode() {
			return Integer.hashCode(id); // 使用id作为哈希码
		}

	public static void main(String[] args) {
		Object obj1 = new Object();
		Object obj2 = new Object();

		// 假设这两个不同的对象产生了相同的哈希码
		System.out.println(obj1.hashCode()); // 比如返回了1
		System.out.println(obj2.hashCode()); // 比如也返回了1

		// 尽管它们根据equals()方法比较不相等
		System.out.println(obj1.equals(obj2)); // 输出false
	}
}